import Vue from "vue";
import VueRouter, { RouteConfig } from "vue-router";
import { ViewItems } from "@/model/ViewItem";

Vue.use(VueRouter);

const routes: Array<RouteConfig> = [];

routes.push(
  ...ViewItems.Instance().Group.map<RouteConfig>(item => {
    return {
      path: item.RoutePath,
      name: item.Name,
      component: () => import(`@/views/${item.FilePath}`)
    };
  })
);

const router = new VueRouter({
  routes
});

export default router;
